package com.stars.pao.junit01;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.CsvSource;
import org.springframework.expression.ParseException;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @Description:
 * @Param: * @param null
 * @return:
 * @Author: wlx
 * @Date: 20:01 2025/2/21
 */

class TriangleTest {

    @Test
    @DisplayName(value = "不等边三角形")
    void testTriangle() {
        Triangle triangle = new Triangle();
        String type = triangle.classify(3, 4, 5);
        assertEquals("不等边三角形", type);
    }

    @Test
    void equalTriangle() {
        Triangle triangle = new Triangle();

        String type = triangle.classify(3, 3, 3);
        assertEquals("等边三角形", type);
    }

    @Test
    void notTriangle() {
        Triangle triangle = new Triangle();

        String type = triangle.classify(3, 3, 6);
        assertEquals("非三角形", type);
    }

    // 主要使用这个注释 传参
    @ParameterizedTest
    @CsvSource({
            "3,4,6,不等边三角形",
            "5,5,5,等边三角形",
            "3,3,5,等腰三角形"
    })
    void paramTriangle(int a, int b, int c, String expected) {
        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }

    @DisplayName(value = "三角形一般边界测试用例")
    @ParameterizedTest
    @CsvFileSource(resources = "/三角形一般边界测试用例.csv", numLinesToSkip = 1, encoding = "UTF-8")
    void fileTest(int m, int a, int b, int c, String expected) throws ParseException {

        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }

    @DisplayName(value = "三角形健壮性最坏情况测试用例")
    @ParameterizedTest
    @CsvFileSource(resources = "/三角形健壮性最坏情况测试用例.csv", numLinesToSkip = 1, encoding = "UTF-8")
    void fileTest1(int m, int a, int b, int c, String expected) throws ParseException {

        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }

    @DisplayName(value = "三角形健壮测试用例")
    @ParameterizedTest
    @CsvFileSource(resources = "/三角形健壮测试用例.csv", numLinesToSkip = 1, encoding = "UTF-8")
    void fileTest2(int m, int a, int b, int c, String expected) throws ParseException {

        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }

    @DisplayName(value = "三角形弱一般等价类测试用例")
    @ParameterizedTest
    @CsvFileSource(resources = "/三角形弱一般等价类测试用例.csv", numLinesToSkip = 1, encoding = "UTF-8")
    void fileTest3(int m, int a, int b, int c, String expected) throws ParseException {

        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }

    @DisplayName(value = "三角形最坏情况测试用例")
    @ParameterizedTest
    @CsvFileSource(resources = "/三角形最坏情况测试用例.csv", numLinesToSkip = 1, encoding = "UTF-8")
    void fileTest4(int m, int a, int b, int c, String expected) throws ParseException {

        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }

    @DisplayName(value = "健壮性边界值方法测试用例")
    @ParameterizedTest
    @CsvFileSource(resources = "/健壮性边界值方法测试用例.csv", numLinesToSkip = 1, encoding = "UTF-8")
    void fileTest5(int m, int a, int b, int c, String expected) throws ParseException {

        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }


}

